//
// Created by htlin on 2021/3/5 0005.
//

#ifndef LIBUVTEST_THREADASYNC_H
#define LIBUVTEST_THREADASYNC_H

#include "ThreadAsyncData.h"

class ThreadAsyncPrivateData;

class ThreadAsync {
public:
    typedef void (*AsyncCallback)(ThreadAsyncData *data);

public:
    explicit ThreadAsync(uv_loop_t *loop, ThreadAsyncData *threadAsyncData);

    ~ThreadAsync();

    void setAsyncCB(AsyncCallback asyncCallback);

    void sendAsync(void *data);

    ThreadAsyncData *getThreadAsyncData();

private:
    static void asyncCB(uv_async_t *data);

private:
    std::unique_ptr<ThreadAsyncPrivateData> data;
};


#endif //LIBUVTEST_THREADASYNC_H
